﻿

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>结算</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all">
</head>
<body>

    <div class="layui-fluid">

        <div class="layui-card">
            <div class="layui-form layui-card-header layuiadmin-card-header-auto">
                <div class="layui-form-item ">
                    <div class="layui-inline layui-col-lg2">
                        <label class="layui-form-label">收货人姓名</label>
                        <div class="layui-input-block">
                            <input type="text" name="txt_name" id="txt_name" placeholder="收货人姓名" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline layui-col-lg2">
                        <label class="layui-form-label">联系方式</label>
                        <div class="layui-input-block">
                            <input type="text" name="txt_tel" id="txt_tel" placeholder="联系方式" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline layui-col-lg6">
                        <label class="layui-form-label">收货人地址</label>
                        <div class="layui-input-block">
                            <input type="text" name="txt_address" id="txt_address" placeholder="收货人地址" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-card-body">

                <div class="layui-btn-group test-table-operate-btn" style="display:none;">
                    <input id="uidsub" class="form-control" name="uid" type="hidden" value="">
                    <button class="layui-btn" id="saveBtn_js" data-type="getCheckData"></button>
                </div>
                <div class="layui-card-body">
                    <table id="LAY-user-manage" lay-filter="LAY-user-manage"></table>
                </div>

                <script type="text/html" id="buttonTpl">
                    {{#  if(d.status == 99){ }}
                    <button class="layui-btn layui-btn-xs">已审核</button>
                    {{#  } else if(d.status == 1){ }}
                    <button class="layui-btn layui-btn-primary layui-btn-xs">已发布</button>
                    {{#  } else if(d.status == 0){ }}
                    <button class="layui-btn layui-btn-primary layui-btn-xs">未发布</button>
                    {{#  } else if(d.status == -1){ }}
                    <button class="layui-btn layui-btn-danger layui-btn-xs">驳回</button>
                    {{#  } else { }}
                    <button class="layui-btn layui-btn-primary layui-btn-xs">未审核</button>
                    {{#  } }}
                </script>

                <script type="text/html" id="test-table-operate-td">
                    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
                </script>

                <script type="text/html" id="imgTpl">
                    <img style="width: 100px; height: 100px;" src={{ d.imageurl }}>
                </script>
            </div>
        </div>
    </div>
    <script src="../../layuiadmin/js/jquery.min2.1.4.js"></script>
    <script src="../../layuiadmin/layui/layui.js"></script>
    <script src="../../layuiadmin/js/cookie.js"></script>
    <script>
   
        layui.config({
            base: '../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'useradmin', 'util', 'table', 'laypage', 'dropdown', 'laydate', 'layer'], function () {
            var $ = layui.$
                , form = layui.form
                , table = layui.table
                , layer = layui.layer
                , laypage = layui.laypage
                , laydate = layui.laydate
                , util = layui.util
                , dropdown = layui.dropdown;
            //验证用户是否登录
            if ($.cookie("loginid") == "" || $.cookie("loginid") == null || $.cookie("loginid") == "null" || $.cookie("loginid") == undefined || $.cookie("loginid") == "undefined") {
                $.removeCookie("id", { path: "/", sucue: true });//用户id
                $.removeCookie("loginid", { path: "/", sucue: true });//登录账号
                $.removeCookie("username", { path: "/", sucue: true });//用户名
                $.removeCookie("role", { path: "/", sucue: true });//权限
                $.removeCookie("islookme", { path: "/", sucue: true });//权限
                window.location.href = "../login/login.html";
            }
            //数据列表加载
            table.render({
                elem: '#LAY-user-manage'
                , id: 'testReload'//容器的ID
                , url: 'ashx/list.ashx?type=getaccountlist&userid=' + $.cookie("id")
                , toolbar: '#test-table-radio-toolbarDemo'
                , lineStyle: 'height: 100px'
                , method: 'POST'
                , page: true
                , limits: [10, 20, 30]
                , limit: 30
                , cols: [[
                    { type: 'checkbox' }
                    , { field: 'tmid', hide: true }
                    , { field: 'accountid', hide: true }
                    , { field: 'imageurl', width: 120, title: '图片', align: 'center', templet: '#imgTpl' }
                    , { field: 'sale_code', hide: true }
                    , { field: 'username', width: 130, title: '出售方', align: 'center' }
                    , { field: 'productvalue', width: 150, title: '款号', align: 'center' }
                    , { field: 'color', width: 100, title: '颜色', align: 'center' }
                    , { field: 'cmwm', width: 100, title: '尺码', align: 'center' }
                    , { field: 'nf', width: 100, title: '年份', align: 'center' }
                    , { field: 'jj', width: 100, title: '季节', align: 'center' }
                    , { field: 'sl', width: 100, title: '数量', align: 'center' }
                    , { field: 'createtime', width: 160, title: '发布时间', align: 'center', sort: true }
                    , { width: 200, align: 'center', fixed: 'right', toolbar: '#test-table-operate-td' }
                ]], parseData: function (res) { //将原始数据解析成 table 组件所规定的数据.
                    return {
                        "code": res.code, //解析接口状态
                        "msg": res.msg, //解析提示文本
                        "count": res.count, //解析数据长度
                        "data": res.data //解析数据列表
                    };
                }, where: {
                    customer_name: $('#customer_name').val()
                    , productvalue: $('#productvalue').val()
                    , productname: $('#productname').val()
                }
            });
            //监听排序
            table.on('sort(LAY-user-manage)', function (obj) { //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
                table.reload('testReload', {//刷新列表
                    initSort: obj //记录初始排序，如果不设的话，将无法标记表头的排序状态。 layui 2.1.1 新增参数
                    , where: { //请求参数
                        field: obj.field //排序字段
                        , order: obj.type //排序方式
                        , customer_name: $('#customer_name').val()
                        , productvalue: $('#productvalue').val()
                        , productname: $('#productname').val()
                    }
                });
            });
            //监听工具条
            table.on('tool(LAY-user-manage)', function (obj) {
                var data = obj.data;
                //删除
                if (obj.event === 'del') {
                    layer.confirm('您确定要删除吗', function (index) {
                        $.ajax({
                            url: 'ashx/list.ashx?type=accountdelete&getaccountid=' + data.accountid,
                            type: "post",
                            contentType: "application/json",
                            dataType: "json",
                            data: {},
                            success: function (res) {
                                var index = parent.layer.getFrameIndex(window.name);
                                if (res.flag == "True") {
                                    layer.msg(res.remsg, {
                                        time: 2000,
                                        end: function () {
                                            table.reload('testReload', {//刷新列表
                                                where: { //请求参数
                                                     customer_name: $('#customer_name').val()
                                                    , productvalue: $('#productvalue').val()
                                                    , productname: $('#productname').val()
                                                }
                                            });
                                        }
                                    })
                                }
                                else {
                                    layer.alert(res.remsg);
                                }
                            }
                        });
                    });
                }
            });
            //监听搜索
            form.on('submit(LAY-user-front-search)', function (data) {
                var field = data.field;
                //执行重载
                table.reload('testReload', {
                    where: {
                        docno: $('#docno').val()
                        , customer_name: $('#customer_name').val()
                        , productvalue: $('#productvalue').val()
                        , status: $("select[name='status']").val()

                    }, page: {
                        curr: 1 //重新从第 1 页开始
                    }
                });
            });
            function getRowFexId(value) {
                var checkStatus = table.checkStatus('testReload')
                    , data = checkStatus.data, arr = new Array();;
                for (var i = 0; i < data.length; i++) {
                    arr.push(data[i][value]);
                }
                return arr.join(",");
            }

            /*点击确定*/
            $("#saveBtn_js").on('click', function () {
                var checkStatus = table.checkStatus('testReload');
                if (!checkStatus.data.length) { //判断，如果没有选择提示
                    layer.msg('请选择数据', { icon: 7 }); return;
                }
                else {//否则，序列化为Json字符串，存放在视图页面中
                    $("#uidsub").val(JSON.stringify(checkStatus.data));
                    //关闭层
                    if ($("#uidsub").val() != null || $("#uidsub").val() != '') {
                        //var index = parent.layer.getFrameIndex(window.name);
                        //parent.layer.close(index);
                    }
                }

            });
            //头工具栏事件
            table.on('toolbar(test-table-radio)', function (obj) {
                var checkStatus = table.checkStatus(obj.config.id); //获取选中行状态
                switch (obj.event) {
                    case 'getCheckData':
                        var data = checkStatus.data;  //获取选中行数据
                        layer.alert(JSON.stringify(data));
                        break;
                };
            });
            $('.layui-btn.layuiadmin-btn-useradmin').on('click', function () {
                var type = $(this).data('type');
                active[type] ? active[type].call(this) : '';
            });
        });
    </script>
</body>
</html>
